package com.ranchuanyin.schoolcat.controller;

import com.ranchuanyin.schoolcat.units.RestBean;
import com.ranchuanyin.schoolcat.util.MinioUtil;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@Slf4j
@RestController
@RequestMapping("/cat/upload")
public class FileUploadController {
    @Resource
    private MinioUtil minioUtil;

    @PostMapping("/avatar-img")
    public RestBean<String> uploadImage(@RequestParam("file") MultipartFile file) throws IOException {
        String upload = minioUtil.upload(file);

        return RestBean.success("修改成功", upload);
    }
}
